home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_535 / keymacro / keysupport.c < prev    next >
Text File  |  1992-05-06  |  2KB  |  73 lines

  1. /****************************************************************************
  2. *
  3. *    KeySupport.c ----------    Keymacro support routines.
  4. *
  5. *    Author ----------------    Olaf Barthel, MXM
  6. *                Brabeckstrasse 35
  7. *                D-3000 Hannover 71
  8. *
  9. *    KeyMacro  ©  Copyright  1990  by  MXM;  Executable  program,
  10. *    documentation  and  source  code are shareware.  If you like
  11. *    this  program  a  small donation will entitle you to receive
  12. *    updates and new programs from MXM.
  13. *
  14. ****************************************************************************/
  15.  
  16.     /* AllocRem():
  17.      *
  18.      *    Allocate public memory and keep track of its size.
  19.      */
  20.  
  21. VOID *
  22. AllocRem(LONG ByteSize,LONG Requirements)
  23. {
  24.     LONG    *MemoryBlock = NULL;
  25.     LONG     RemSize = ByteSize + sizeof(LONG);
  26.  
  27.     if(ByteSize > 0)
  28.         MemoryBlock = (LONG *)AllocMem(RemSize,Requirements);
  29.  
  30.     if(MemoryBlock)
  31.         *MemoryBlock++ = RemSize;
  32.  
  33.     return((VOID *)MemoryBlock);
  34. }
  35.  
  36.     /* FreeRem():
  37.      *
  38.      *    Free a tracked portion of memory.
  39.      */
  40.  
  41. VOID *
  42. FreeRem(LONG *MemoryBlock)
  43. {
  44.     if(MemoryBlock--)
  45.         FreeMem(MemoryBlock,*MemoryBlock);
  46.  
  47.     return(NULL);
  48. }
  49.  
  50.     /* SendMacroMsg(scm_Msg,scm_Port):
  51.      *
  52.      *    Post a cloned macro message to a MsgPort.
  53.      */
  54.  
  55. VOID *
  56. SendMacroMsg(struct MacroMessage *scm_Msg,struct MsgPort *scm_Port)
  57. {
  58.     struct MacroMessage *scm_TempMsg;
  59.  
  60.     if(scm_TempMsg = (struct MacroMessage *)AllocRem(sizeof(struct MacroMessage),MEMF_PUBLIC | MEMF_CLEAR))
  61.     {
  62.         CopyMem(scm_Msg,scm_TempMsg,sizeof(struct MacroMessage));
  63.  
  64.         scm_TempMsg -> mm_Message . mn_Node . ln_Name    = (char *)scm_TempMsg;
  65.         scm_TempMsg -> mm_Message . mn_ReplyPort    = NULL;
  66.         scm_TempMsg -> mm_Message . mn_Length        = sizeof(struct MacroMessage);
  67.  
  68.         PutMsg(scm_Port,(struct Message *)scm_TempMsg);
  69.     }
  70.  
  71.     return((VOID *)scm_TempMsg);
  72. }
  73.